<template>
  <div class="main">
    <van-sticky>
      <div class="nav">
        <img :src="back" alt="" @click="handleBack"/>
        <div>查看订单</div>
      </div>
    </van-sticky>
    <van-tabs v-model="active" @click="chooseTab">
      <van-tab :title="obj.name" :name="obj.name" v-for="obj in channels" :key="obj.id">
        <!-- 订单列表 -->
        <keep-alive>
          <order-list :obj=obj></order-list>
        </keep-alive>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import orderList from "./components/orderList";

export default {
  name: "index",
  components: {
    orderList
  },
  data() {
    return {
      active: 2,
      channels: [
        {name: '全部', id: ''},
        {name: '待支付', id: 0},
        {name: '待发货', id: 1},
        {name: '待收货', id: 2},
      ],
      back: require("@/assets/my/back.png"),
    }
  },
  mounted() {
    this.active = this.$route.query.activeTab
    // console.log('--active--', this.active)
  },
  methods: {
    chooseTab(item) {
      console.log('-----------q',item)
      this.active = item
    },
    handleBack() {
      // this.$router.go(-1);
      this.$router.push({path:'/my'})
      let message = {
        action: 'showBottom',
        param: {}
      }
      getInfoFromVue.postMessage(JSON.stringify(message))
    },
  }
}
</script>

<style scoped lang="less">
.main {
  background: #f2f2f2;
  height: 100vh;

  .nav {
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    font-size: 20px;
    font-weight: 500;

    > img {
      width: 10px;
      height: 16px;
      position: absolute;
      left: 15px;
    }
  }

  /deep/ .van-tabs__line {
    background: rgba(242, 150, 0, 1);
    width: 23px;
    height: 2px;
  }

  /deep/ .van-nav-bar__content {
    height: 48px;
    // 标题
    .van-nav-bar__title {
      // 不要默认设置最大宽度
      //max-width: unset;
      font-size: 14px;
    }
  }

  /deep/ .van-tabs--line .van-tabs__wrap {
    height: 44px;
  }

  /deep/ .van-tab--active {
    color: rgba(242, 150, 0, 1) !important;
  }

  /deep/ .van-tab {
    font-weight: 500;
    font-size: 20px;
    color: rgba(128, 128, 128, 1);
    text-align: center;
  }

  /deep/ .van-tabs__nav--line.van-tabs__nav--complete {
    //background: rgba(247, 247, 247, 1);
  }

}
</style>
